package com.njtcedu.microblog.common.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonIgnore;

@Entity
@Table(name = "content", schema = "microblog")
public class Content implements Serializable {

	@Id
	@GeneratedValue
	@Column(name = "id")
	private Integer id;

	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "user_id", nullable = false)
	private User user;

	@Column(name = "send_content", length = 500, nullable = true)
	private String sendContent;// 发送内容


	@Column(name = "content_Type", length = 255,  nullable = false)
	private String contentType;
	
	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "topic_id", nullable = false)
	private Topic topic;

	@Column(name = "status", length = 1, nullable = false)
	private String status;
	
	@Column(name = "sendDate", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date sendDate;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getSendContent() {
		return sendContent;
	}

	public void setSendContent(String sendContent) {
		this.sendContent = sendContent;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Topic getTopic() {
		return topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public Date getSendDate() {
		return sendDate;
	}

	public void setSendDate(Date sendDate) {
		this.sendDate = sendDate;
	}

	@Override
	public int hashCode() {
		return id != null ? id.hashCode() : 0;
	}

	@Override
	public boolean equals(Object object) {
		if(this == object) return true;
		if(null == object || getClass() != object.getClass()) return false;
		Content content = (Content)object;
		return id != null ? id.equals(content.id) : content.id == null;
	}

	@Override
	public String toString() {
		return "Content [id=" + id + ", user=" + user + ", sendContent="
				+ sendContent + ", contentType=" + contentType + ", status="
				+ status + "]";
	}
}
